from flask import request
import hashlib

def signature(a, b):
    base = a + str(time.time()) + b + str(random.random())
    return hashlib.md5(base).hexdigest().upper()


def get_real_addr():
    if 'HTTP_CLIENTIP' in request.environ:
        return request.environ['HTTP_CLIENTIP']
    elif 'HTTP_X_FORWARDED_FOR' in request.environ:
        return request.environ['HTTP_X_FORWARDED_FOR'].split(',', -1)[0]
    elif 'HTTP_X_REAL_IPHTTP_CLIENTIP' in request.environ:
        return request.environ['HTTP_X_REAL_IP'].split(',', -1)[0]
    else:
        return request.remote_addr

